<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUserInvoicesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_invoices', function (Blueprint $table) {
            $table->id()->comment('用户发票记录表');
            $table->integer('user_id')->comment('用户id')->index();
            $table->integer('order_id')->comment('订单id')->index();
            $table->tinyInteger('header_type')->default(0)->comment('抬头类型 0:个人 1：企业');
            $table->tinyInteger('type')->default(0)->comment('发票类型 0:普通 1:专用');
            $table->string('name')->comment('发票抬头名称');
            $table->string('duty_number')->comment('税号');
            $table->char('drawer_phone',15)->comment('开票人手机号');
            $table->string('email',50)->nullable()->comment('开票人邮箱');
            $table->string('tell',30)->nullable()->comment('注册电话');
            $table->string('address')->nullable()->comment('注册电话');
            $table->string('bank')->comment('注册开户银行');
            $table->string('card_number',100)->comment('银行卡号');
            $table->string('invoice_status')->default('notInvoiced')->comment('发票状态: 未开发票:notInvoiced 已开发票:invoiced 退款发票:refundInvoiced');
            $table->tinyInteger('is_default')->default(0)->comment('是否默认 0:不是默认 1:默认');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_invoices');
    }
}
